package com.chenyi.data.structure.queue;

import java.util.Scanner;

/**
 * @author by chenyi
 * @className TestMain
 * @date 2021/12/16 19:02
 */

public class TestMain {

    public static void main(String[] args) {
        testQueue(new LinkedQueue(3));
    }

    public static void testRingArrayQueue() {
        RingArrayQueue ringArrayQueue = new RingArrayQueue(3);
        ringArrayQueue.addQueue(1);
        ringArrayQueue.addQueue(2);
        ringArrayQueue.addQueue(3);

        boolean full = ringArrayQueue.isFull();
        System.out.println(full);

        ringArrayQueue.getQueue();
        ringArrayQueue.getQueue();
        ringArrayQueue.getQueue();
        System.out.println(ringArrayQueue.isEmpty());

        ringArrayQueue.addQueue(1);
        ringArrayQueue.addQueue(2);
        ringArrayQueue.addQueue(3);
        System.out.println(ringArrayQueue.isFull());
    }

    public static void testQueue(Queue queue) {
        boolean flag = true;
        Scanner scanner = new Scanner(System.in);
        while (flag) {
            System.out.println("=========================");
            System.out.println("请选择要执行的操作：");
            System.out.println("显示队列：s");
            System.out.println("推出程序：e");
            System.out.println("添加数据队列：a");
            System.out.println("从队列取出数据：g");
            System.out.println("查看队列头的数据：h");
            String key = scanner.nextLine();
            switch (key) {
                case "s":
                    queue.showQueue();
                    break;
                case "a":
                    System.out.println("请输入要添加的数据");
                    int i = scanner.nextInt();
                    boolean b = queue.addQueue(i);
                    System.out.println(b);
                    break;
                case "g":
                    int g = queue.getQueue();
                    System.out.println(g);
                    break;
                case "h":
                    int i1 = queue.peekHeadQueue();
                    System.out.println(i1);
                    break;
                case "e":
                    flag = false;
                    System.out.println("程序已退出");
                    break;
            }
        }
    }

}
